package com.bookmarket.test;

import com.bookmarket.entity.Book;
import com.bookmarket.entity.Discount;
//import com.bookmarket.entity.Stype;
//import com.bookmarket.service.BookService;
import com.bookmarket.service.CzgChaxunService;
import com.bookmarket.service.CzgIDiscountService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Chen Zhaoguang
 * @date 2018/1/2 16:21
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-mybatis.xml")
public class CzgDemo {
    @Resource
    private CzgIDiscountService czgIDiscountService;

    //@Resource
    //private BookService bookService;


    @Resource
    private CzgChaxunService czgChaxunService;


    @Test
    public void test1(){
        Map<String,Object> map=new HashMap<>();
        Discount d=new Discount();
        d.setConditio(10);
        d.setCoun(10);
        d.setMoney(10);
        d.setName("bb");
        d.setRemain(10);
        map.put("eTime","1995-01-20 00:00:00");
        map.put("sTime","1995-01-20 00:00:00");
        map.put("discount",d);
        czgIDiscountService.addDiscount(map);
    }
    @Test
    public void test2(){
        Map<String,Object> map=new HashMap<>();
        Discount d = new Discount();
        d.setId(35);
        d.setConditio(10);
        d.setCoun(10);
        d.setMoney(10);
        d.setName("bb");
        d.setRemain(10);
        map.put("discount",d);
        czgIDiscountService.editDiscount(map);
    }

    /*@Test
    public void test3(){
        List<Stype> list=bookService.getstype(3);
        for (Stype s: list) {
            System.out.println(s.getType());
        }
    }*/
    @Test
    public void test4(){
        List<Book> list = czgChaxunService.getBookByStype(1);
        for (Book b: list) {
            System.out.println(b.getName());
        }
    }

    @Test
    public void test5(){
        List<String> list = czgChaxunService.getBookByKeyword("西");
        for (String b: list) {
            System.out.println(b);
        }
    }



    public CzgChaxunService getCzgChaxunService() {
        return czgChaxunService;
    }

    public void setCzgChaxunService(CzgChaxunService czgChaxunService) {
        this.czgChaxunService = czgChaxunService;
    }

    /*public BookService getBookService() {
        return bookService;
    }

    public void setBookService(BookService bookService) {
        this.bookService = bookService;
    }*/

    public CzgIDiscountService getCzgIDiscountService() {
        return czgIDiscountService;
    }

    public void setCzgIDiscountService(CzgIDiscountService czgIDiscountService) {
        this.czgIDiscountService = czgIDiscountService;
    }
}
